package com.ncr.travel.tas.testing.hamcrest.matchers;

import static org.hamcrest.Matchers.equalTo;

import org.hamcrest.Matcher;
import org.json.JSONObject;

/**
 * @author ma250087
 * 
 */
public final class JsonMatchers {

	private JsonMatchers() {
		// do not initialize. This is a matcher factory.
	}

	/**
	 * Builds a Matcher<JSONObject> instance that can match if a key with name
	 * specified is contained in the JSONObject.
	 * 
	 * @param key
	 *            key name
	 * @return Matcher<JSONObject>
	 */
	public static Matcher<JSONObject> hasJsonKey(String key) {
		return HasJsonKeyMatcher.hasJsonKey(key);
	}

	/**
	 * Builds a Matcher<JSONObject> instance that can match if a value with
	 * object specified is contained in the JSONObject when given that the key
	 * matches with the name specified.
	 * 
	 * @param key
	 *            key name
	 * @param value
	 *            Object value
	 * @return Matcher<JSONObject>
	 */
	public static Matcher<JSONObject> hasJsonValue(String key, Object value) {
		return HasJsonValueMatcher.hasJsonValue(equalTo(key), value);
	}
}